<!-- 歌唱-->
<template>
  <div class="exam-box">
    <!-- :number="$route.query.examinee_number" -->
    <!-- <navBar title="2024中国音乐小金钟合唱江西省选拔赛" /> -->
    <div>2024中国音乐小金钟合唱江西省选拔赛</div>
    <ul class="main flex">
      <!-- 视频 -->

      <li class="main-item">
        <div class="video-box">
          <ul class="content">
            <li class="content-item">
              {{ info.subject_name }}{{ info.subject_level_name }}
            </li>
            <div class="item-box" v-if="playerList.length != 0">
              <li class="content-item flex align">
                视频<span v-if="info.name != ''">({{ info.name }})</span>
              </li>
              <div v-for="(item, index) in playerList" :key="index">
                <li class="content-item">
                  <!-- 视频播放 -->
                  <!-- <viewer>
                    <img
                      width="10%"
                      height="20%"
                      :src="avatar"
                      class="message"
                      alt="照片不存在或已损坏，请联系管理员~"
                    />
                  </viewer> -->
                  <!-- <el-button :loading="true" class="loading">加载中</el-button> -->
                  <video-player
                    class="video-player vjs-custom-skin"
                    ref="videoPlayer"
                    @loadeddata="onPlayerLoadeddata($event)"
                    @waiting="wait($event)"
                    :playsinline="true"
                    :options="playerList[index]"
                  ></video-player>
                </li>
              </div>
            </div>
          </ul>
        </div>
      </li>
      <!-- 打分 -->
      <li class="main-item">
        <ul class="main-right">
          <li class="icons flex align">评审打分</li>
          <li class="label-scorce">
            <input
              @input="input($event)"
              v-model="score"
              type="number"
              class="input-scorce"
              placeholder="输入您要给的分数0~10"
            />
          </li>
          <Canvas class="qianmin" @getSignin="getMsg">
            <template>
              <el-button class="btn" @click="nextTap" :disabled="disabled"
                >完成阅卷</el-button
              >
            </template>
          </Canvas>
          <li></li>
        </ul>
      </li>
    </ul>
  </div>
</template>

<script>
import navBar from "@/components/navBar";
import Canvas from "@/components/canvas2";
import { getExamItemInfo, examinerDetail } from "@/api/apiData";
import { mapState, mapMutations } from "vuex";
export default {
  name: "singerResult",
  components: { navBar, Canvas },
  data() {
    return {
      radio: "",
      checkList: [],
      statusList: [], //综合评价标签
      info: [], //题目信息
      textarea: "",
      feelList: [
        {
          id: 1,
          name: "音准节奏",
        },
        {
          id: 2,
          name: "情感表现",
        },
        {
          id: 3,
          name: "发声吐字",
        },
        {
          id: 4,
          name: "仪态修养",
        },
      ],
      tagList: [], //获取综合评价标签
      playerList: [],
      idList: [null, null, null, null],
      signin: "",
      arr: [],
      disabled: false,
      showComm: false,
      pingList: [],
      score: "",
      fileList: [],
      rating: "",
      rating_status: "",
    };
  },
  computed: { ...mapState(["avatar"]) },
  methods: {
    ...mapMutations(["saveSign"]),
    // 分数
    input(val) {
      let score = this.score;
      let message;
      if (Number(10) < score) {
        message = "输入的分数不能大于该题总分数~";
        this.$alert(message, "温馨提示", {
          confirmButtonText: "确定",
          showClose: false,
        });
      }
    },
    getMsg(e) {
      this.signin = e;
    },
    // 获取视频考试信息
    getVideoInfo() {
      const that = this;
      const { query } = that.$route;
      that.rating_status = query.rating_status;
      let obj = {
        product_id: 1,
      };
      let playerList = [];
      examinerDetail(obj).then((res) => {
        if (res.code == 1) {
          const subList = res.data;
          that.info = subList;
          if (that.rating_status == 2) {
            that.score = subList.rating.score;
          }
          if (res.data.file != "") {
            let file = res.data.file.split(",");
            console.log(file);
            this.fileList = file;
            file.forEach((item, index) => {
              // 视频播放
              let playerOptions = {
                playbackRates: [0.5, 1.0, 1.5, 2.0], //可选择的播放速度
                autoplay: false, //如果true,浏览器准备好时开始回放。
                muted: false, // 默认情况下将会消除任何音频。
                loop: false, // 视频一结束就重新开始。
                preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
                language: "zh-CN",
                aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
                fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
                sources: [
                  {
                    type: "video/mp4",
                    src: item, //url地址
                  },
                ],
                poster: "", //你的封面地址
                // width: document.documentElement.clientWidth,
                notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
                controlBar: {
                  timeDivider: true, //当前时间和持续时间的分隔符
                  durationDisplay: true, //显示持续时间
                  remainingTimeDisplay: false, //是否显示剩余时间功能
                  fullscreenToggle: true, //全屏按钮
                },
              };
              playerList.push(playerOptions);
            });
            that.playerList = playerList;
          }
          //   subList.forEach((item, index) => {
          //     // 视频播放
          //     let playerOptions = {
          //       playbackRates: [0.5, 1.0, 1.5, 2.0], //可选择的播放速度
          //       autoplay: false, //如果true,浏览器准备好时开始回放。
          //       muted: false, // 默认情况下将会消除任何音频。
          //       loop: false, // 视频一结束就重新开始。
          //       preload: "auto", // 建议浏览器在<video>加载元素后是否应该开始下载视频数据。auto浏览器选择最佳行为,立即开始加载视频（如果浏览器支持）
          //       language: "zh-CN",
          //       aspectRatio: "16:9", // 将播放器置于流畅模式，并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字（例如"16:9"或"4:3"）
          //       fluid: true, // 当true时，Video.js player将拥有流体大小。换句话说，它将按比例缩放以适应其容器。
          //       sources: [
          //         {
          //           type: "video/mp4",
          //           src: item.file, //url地址
          //         },
          //       ],
          //       poster: "", //你的封面地址
          //       // width: document.documentElement.clientWidth,
          //       notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
          //       controlBar: {
          //         timeDivider: true, //当前时间和持续时间的分隔符
          //         durationDisplay: true, //显示持续时间
          //         remainingTimeDisplay: false, //是否显示剩余时间功能
          //         fullscreenToggle: true, //全屏按钮
          //       },
          //     };
          //     playerList.push(playerOptions);
          //   });
        } else {
          that.$message({
            message: res.msg,
            type: "error",
          });
          //   setTimeout(() => {
          //     that.$router.back();
          //   }, 1500);
        }
      });
    },
    // 视频缓冲
    wait(e) {
      //("视频缓冲中");
    },
    // 视频数据在加载
    onPlayerLoadeddata(e) {
      //(" 视频数据在加载");
    },
    // 获取综合评价标签
    rest() {
      const that = this;
      that.tagList = []; //获取综合评价标签
      that.playerList = [];
      that.idList = [null, null, null, null];
      that.signin = "";
      that.arr = [];
      that.disabled = false;
      that.radio = "";
      that.checkList = [];
      that.statusList = []; //综合评价标签
      that.info = []; //题目信息
      that.textarea = "";
      that.getVideoInfo();
    },
    // 完成阅卷
    nextTap() {
      const that = this;
      let { textarea, idList, signin, radio, arr, score } = that;
      if (score == "") {
        this.$notify({
          title: "提示",
          message: "请给视频打分~",
          type: "warning",
          duration: 2000,
        });
        return;
      }
      if (!signin[0]) {
        this.$notify({
          title: "提示",
          message: "请签名并且保存之后再提交~",
          type: "warning",
          duration: 2000,
        });
        return;
      }
      const { query } = that.$route;
      //   保存改卷内容
      that.disabled = true;
      let obj = {
        subject_record_id: query.subject_record_id,
        examiner_sign: signin[0],
        examiner_sign2: signin[1],
        score: score,
      };
      console.log(obj);
      that.disabled = false;
      //   doneSingPaper(obj).then((result) => {
      //     that.disabled = false;
      //     if (result.code == 1) {
      //       that.$notify({
      //         title: "提示",
      //         message: "提交成功~",
      //         type: "success",
      //         duration: 2000,
      //       });
      //       that.saveSign([]);
      //       that.$router.go(-1);
      //     } else {
      //       that.$notify({
      //         title: "提示",
      //         message: result.msg,
      //         type: "error",
      //         duration: 2000,
      //       });
      //     }
      //   });
    },
  },
  created() {},
  mounted() {
    this.rest();
  },
};
</script>
<style lang='less' scoped>
.label-scorce {
  display: block;
  padding: 10px 0;
  font-size: 20px;
  color: #212121;
  margin-bottom: 20px;
  .input-scorce {
    border: 0;
    border-bottom: 1px solid #000;
    width: 100%;
    padding: 10px 0;
  }
  .input-scorce:focus {
    border-color: @main-color;
  }
}

.exam-box {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}
/deep/.qianmin ul {
  padding: 0;
}
.main {
  width: 100%;
  .main-item {
    width: 50%;
    height: 100vh;
    overflow: hidden;
  }
  .main-item::-webkit-scrollbar {
    width: 0;
  }
  .main-item:first-child {
    background: #f6f9fc;
    padding: 46px;
    .video-box {
      width: 100%;
      height: 85%;
      border-radius: 20px;
      background: #fff;
      padding: 30px;
      .content {
        > .content-item:first-child {
          display: inline-block;
          border-radius: 10px;
          border: 3px solid @main-color;
          padding: 0 10px;
          font-size: 32px;
          color: @main-color;
          background: rgba(255, 91, 0, 0.6);
        }
        .item-box {
          .content-item:nth-child(1) {
            font-size: 34px;
            color: #2d2d2d;
            font-weight: bold;
            margin-top: 50px;
            margin-bottom: 20px;
          }
          .content-item:nth-child(1)::before {
            content: "";
            width: 10px;
            height: 34px;
            border-radius: 10px;
            background: rgba(255, 91, 0, 0.6);
            margin-right: 20px;
          }
          .content-item:last-child {
            position: relative;
            .message {
              position: absolute;
              top: 0;
              left: 0;
              z-index: 999;
            }
            .loading {
              position: absolute;
              top: 50%;
              left: 50%;
              transform: translate(-50%, -50%);
              z-index: 90;
              background: rgba(0, 0, 0, 0.6);
              color: #fff;
              border: 0 !important;
            }
          }
        }
      }
    }
  }
  .main-item {
    padding: 25px 65px;
    overflow-y: scroll;
    height: 85vh;
    .title {
      font-size: 34px;
      font-weight: bold;
      color: @main-color;
    }
    .icons {
      color: #2d2d2d;
      font-size: 34px;
      font-weight: 500;
      margin: 20px 0;
    }
    .icons::before {
      content: "";
      width: 7px;
      height: 34px;
      background: rgba(255, 91, 0, 0.6);
      border-radius: 10px;
      margin-right: 15px;
    }
    .box {
      width: 100%;
      margin: auto;
      .feel {
        border-radius: 20px;
        border: 2px solid @main-color;
        margin-bottom: 20px;
        .feel-title {
          font-size: 28px;
          color: @main-color;
          padding: 10px;
          border-right: 2px solid @main-color;
        }
        .feel-item {
          width: 80%;
        }
      }
    }
    /deep/.el-textarea__inner {
      font-size: 28px;
    }
    .radio-item {
      position: relative;
    }
    .radio input[type="radio"] {
      appearance: none;
      -webkit-appearance: none;
      outline: none;
      margin: 0;
      vertical-align: text-bottom;
      margin-right: 0.1rem;
    }
    .radio input[type="radio"]:after {
      display: block;
      content: "\2714";
      width: 30px;
      height: 30px;
      font-size: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgb(138, 138, 138);
      border-radius: 50%;
      color: #fff;
    }

    .radio input[type="radio"]:checked:after {
      content: "\2714";
      font-size: 20px;
      background: @main-color;
      color: #fff;
    }
    .radio {
      position: relative;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 20px;
      font-weight: bold;
      color: #8a8a8a;
    }

    .radio-box {
      background: #f9f9f9;
      border-radius: 14px;
      padding: 24px 10px;
      .el-radio-group {
        display: flex;
        justify-content: space-around;
        /deep/.el-radio__input.is-checked .el-radio__inner {
          border-color: @main-color;
          background: @main-color;
        }
        /deep/.el-radio__label {
          font-size: 24px;
        }
        /deep/.el-radio__input.is-checked + .el-radio__label {
          color: @main-color;
        }
        /deep/.el-radio__input .el-radio__inner::after {
          transform: translate(-50%, -50%) scale(1);
          content: "\2714";
          display: flex;
          align-items: center;
          justify-content: center;
          font-size: 20px;
          background: transparent;
          color: #fff;
        }
        /deep/.el-radio__inner:hover {
          border-color: @main-color;
          background: @main-color;
        }
        /deep/.el-radio__inner {
          width: 30px;
          height: 30px;
          background: rgb(138, 138, 138);
        }
      }
    }

    /deep/.btn {
      display: block;
      width: 80%;
      height: 60px;
      font-size: 30px;
      border-radius: 30px;
      color: #fff;
      background: linear-gradient(to right, #ff8375, #d74939);
      margin: 50px auto;
    }
  }
}
.showBank {
  background: rgba(0, 0, 0, 0.192);
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  .showBankCon {
    position: relative;
    width: 800px;
    padding-bottom: 50px;
    border-radius: 30px;
    background: linear-gradient(to bottom, #d74939, #eeae65, #ffa887);
    .showBankCon-tit {
      color: white;
      font-size: 40px;
      text-align: center;
      div {
        width: 60%;
        margin-left: 30px;
      }
      img {
        width: 25%;
      }
    }
    .bankList {
      max-height: 600px;
      overflow-y: auto;
      color: #d74a39;
      margin: 0 30px;
      display: flex;
      flex-wrap: wrap;
      div {
        background: white;
        font-size: 30px;
        border-radius: 30px;
        width: fit-content;
        padding: 10px 20px;
        margin-bottom: 30px;
        margin-right: 10px;
        cursor: pointer;
      }
      .actTit {
        background: #d74a39;
        color: white;
      }
    }
  }
  .showBankCon2 {
    color: white;
    padding: 20px;
    .showBankCon-tit {
      font-size: 22px;
      text-align: left;
    }
    .item {
      width: fit-content;
      margin: 10px;
      border-bottom: solid 1px;
      cursor: pointer;
      font-size: 20px;
    }
  }
}
</style>